home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 8 code / AUX Hybrid Apps / AUX System Calls / src / sigcode.a < prev    next >
Encoding:
Text File  |  1991-10-09  |  1.6 KB  |  50 lines  |  [TEXT/tefi]

  1. ;    @(;)Copyright Apple Computer 1987    Version 1.2 of sigcode.s on 87/11/11 20:20:38 2.1.1.1 
  2.  
  3. ; aux_sigcode: the interface routine to user's signal handlers.
  4.  
  5. ; The kernel forces the entry to _sigcode with the stack thus:
  6. ;
  7. ;    ----        ; tabu area: the user's stack
  8. ;    long    PC    ; user's program counter
  9. ;    short    CC,kind    ; user's condition codes, stack format flag
  10. ;    long    arg    ; second argument
  11. ;    long    signo    ; first argument.  This is the top of the stack.
  12.  
  13. ; aux_sigcode does this:
  14. ;
  15. ; 1)    save those registers that wouldn't be saved by the user's signal handler
  16. ;
  17. ; 2)    call aux_sigcall(signo, arg) to call the user's signal handler
  18. ;
  19. ; 3)    restore the registers
  20. ;
  21. ; 4)    Pop the stack so that the kernel's stuff is gone,
  22. ;    at the same time restoring the condition codes and pc.
  23. ;    This effects a return to the user's interrupted program.
  24.  
  25.     export    aux_sigcode
  26.     import    aux_sigcall
  27.     import    aux_sysm68k
  28.  
  29. aux_sigcode    proc
  30.     link    a6,#-20        ; push a6; set a6 to sp; decr sp by 5 longs
  31.     movem.l    d0-d1/a0-a1,-16(a6)    ; save a1-a0, d1-d0
  32.     move.l    8(a6),(sp)    ; "push" arg
  33.     move.l    4(a6),-(sp)    ; push signo
  34.     jsr    aux_sigcall    ; call aux_sigcall(signo, arg)
  35.     movem.l    -16(a6),d0-d1/a0-a1    ; restore a1-a0, d1-d0
  36.     unlk    a6        ; restore a6, sp
  37.     tst.w    8(sp)        ; look at the kind flag in the pad word
  38.     beq.b    Lnormal        ; 0 means 'rtr' is usable
  39. ;
  40. ; at this point we need to call the kernel to perform instr cont for us
  41. ;
  42.     add.w    #8,sp        ; pop signo, arg 
  43.     move.l   d0,-(sp)    ; arg1 - old d0 value
  44.     move.l    #2,-(sp)    ; cmd - instruction continue
  45.     jsr    aux_sysm68k    ; no return
  46. Lnormal    add.w    #10,sp        ; pop signo, arg and stack format word
  47.     rtr            ; pop CC into cc, pop PC into pc
  48.     endp
  49.     
  50.     end